package com.lingxu.api.ztb.controller;


import com.lingxu.api.ztb.service.IAViewCspfService;
import com.lingxu.api.ztb.model.AViewCspf;
import com.lingxu.api.ztb.model.vo.AViewCspfVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import com.lingxu.base.common.api.vo.Result;
import com.lingxu.base.common.api.vo.ResultOne;
import com.lingxu.base.common.annotation.Encrypt;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

/**
 * 初设批复 前端控制器
 *
 * @author admin
 * @since 2025-10-15
 */
@Slf4j
@Api(tags = "初设批复", value = "AViewCspfController")
@Validated
@CrossOrigin
@RestController
@RequestMapping("/aViewCspf")
public class AViewCspfController {

    @Autowired
    private IAViewCspfService  aViewCspfService;

    /**
    * 分页查询
    *
    * @param query
    * @return
    */
    @ApiOperation(value="初设批复列表")
    @PostMapping(value = "/list")
    public ResultOne<AViewCspfVO> queryPageList(@RequestBody AViewCspfVO query) {
        return ResultOne.ok(aViewCspfService.queryPageList(query));
    }

    /**
     * 保存
     *
     * @param vo
     * @return
     */
    @ApiOperation(value = "初设批复新增")
    @PutMapping(value = "/add")
    public Result<?> add(@Encrypt @RequestBody AViewCspf vo) {
        aViewCspfService.save(vo);
        return Result.ok("添加成功！");
    }

    /**
    * 修改
    *
    * @param vo
    * @return
    */
    @ApiOperation(value = "初设批复修改")
    @PostMapping(value = "/edit")
    public Result<?> edit(@Encrypt @RequestBody AViewCspf vo) {
        aViewCspfService.updateById(vo);
        return Result.ok("编辑成功!");
    }

    /**
     * 查询详情
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "初设批复查询详情")
    @GetMapping("/get")
    public Result<AViewCspfVO> get(@RequestParam String id){
        return  Result.ok(aViewCspfService.getById(id));
    }

    /**
     * 删除
     *
     * @param ids
     * @return
     */
    @ApiOperation(value = "删除")
    @PostMapping(value = "/delete")
    public Result<String> delete(@Encrypt @RequestBody Set<String> ids){
        aViewCspfService.delete(ids);
        return Result.ok("删除成功!");
    }

}